package com.chhh.cranelease.controller.baseinfocontroller;

import com.chhh.cranelease.entity.CarInfo;
import com.chhh.cranelease.entity.ModelCarane;
import com.chhh.cranelease.entity.Staff;
import com.chhh.cranelease.model.CarInfoDriver;
import com.chhh.cranelease.model.ResponseCode;
import com.chhh.cranelease.service.BaseInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;

@RestController
@RequestMapping("car/")
public class CarInfoController {

    @Autowired
    private BaseInfoService baseInfoService;

    private ResponseCode responseCode = new ResponseCode();

    @RequestMapping("selectAllCar")
    public List<CarInfoDriver> selectAll(String c_num, String c_people){
        return baseInfoService.selectAll(c_num,c_people);
    }

    @RequestMapping("insertNewCar")
    public ResponseCode insertNewCar(CarInfo carInfo){
        baseInfoService.insertNewCar(carInfo);
        responseCode.setErrorCode(1);
        return responseCode;
    }
    @RequestMapping("updateThisCar")
    public ResponseCode updateThisCar(CarInfo carInfo){
        baseInfoService.updateThisCar(carInfo);
        responseCode.setErrorCode(1);
        return responseCode;
    }
    @RequestMapping(value = "deleteThisCar")
    public ResponseCode deleteThisCar(Integer[] c_id){

            baseInfoService.deleteThisCar(c_id);
        responseCode.setErrorCode(1);
        return responseCode;
    }
}
